Run Zig as Script on Linux

Meow King December 02, 2023 Updated: December 02, 2023 #zig #linux #script

Normally, we need to use shabang #! in script header to run a command for this file. Like:

#!/usr/bin/env python

But we can have a tricks. For example, to run a c file using tinycc(better suits into C's comment style):

//usr/bin/tcc -run $0; exit
#include "stdio.h"
#include <stdlib.h>

int main() {
  system("echo El Psy Kongaroo");
}

Now we want to use scriptisco to run our zig file. Same approach.